package com.syq;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Sun Yueqi
 * @version 1.00
 * @time 2022/6/8 19:56
 */
public class TestStream {
    public static void main(String[] args) {
        List<String> list=new ArrayList<>();
        list.add("syq");
        list.add("18");
        list.add("man");
        list.add("student");

        List<Integer> integerList = list.stream()
                .map(String::length).collect(Collectors.toList());
//        System.err.println(integerList);

        List<String> stringList = list.parallelStream()
                .map(s -> s + "(1)").collect(Collectors.toList());

        String[] ss={"abc","sjdakls","shadkhksja","sjhdajksd","shjdayuisndm","smdhajk"};
        List<String> result= Arrays.stream(ss)
                .parallel()
                //遍历后结束
//                .forEach(System.err::println);
                //相当于foreach，但不会结束当前stream
                .peek(System.err::println)
                .filter(s -> s.length() > 5)
                .limit(2)
                .collect(Collectors.toList());
        System.err.println(result);

    }
}
